//package com.weharvest.edu.aspect;
//
//import com.weharvest.edu.constant.CookieConstant;
//import com.weharvest.edu.constant.RedisConstant;
//import com.weharvest.edu.exception.EduCookieException;
//import com.weharvest.edu.utlis.CookieUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.aspectj.lang.annotation.Pointcut;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.stereotype.Component;
//import org.springframework.util.StringUtils;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.annotation.Resource;
//import javax.servlet.http.Cookie;
//import javax.servlet.http.HttpServletRequest;
//
//@Aspect
//@Component
//@Slf4j
//public class EduAspect {
//
//
//    @Resource
//    private StringRedisTemplate stringRedisTemplate;
//
//    @Pointcut("execution( public * com.weharvest.edu.controller.app.Backstage*.*(..)) " +
//            "|| execution(public * com.weharvest.edu.controller.EduController.index(..))")
//    public void verify(){
//
//    }
//    @Before("verify()")
//    public void deoVerify(){
//        ServletRequestAttributes attributes =(ServletRequestAttributes ) RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request =attributes.getRequest();
//        //查看cooklie
//        Cookie cookie = CookieUtil.get(request,CookieConstant.TOKEN);
//        if(null ==cookie){
//            log.warn("[登录检验]cookie查询不到token");
//            throw  new EduCookieException();
//        }
//        //查看redis
//       String tokenValue=
//               stringRedisTemplate.opsForValue().get(String.format(RedisConstant.TOKEN,cookie.getValue()));
//        if(StringUtils.isEmpty(tokenValue)){
//            log.warn("[登录检验]cookie查询不到token");
//            throw  new EduCookieException();
//        }
//    }
//}
